package com.jeasonzhao.report.vml.contrib;

import com.jeasonzhao.report.vml.base.Color;
import com.jeasonzhao.report.vml.base.Rect;
import com.jeasonzhao.report.vml.chart.data.Element;
import com.jeasonzhao.report.vml.chart.data.ElementCollection;
import com.jeasonzhao.report.vml.chart.data.Range;
import com.jeasonzhao.report.vml.chart.data.RangeCollection;


public abstract class BaseGuage extends Rect
{
    protected Range m_limites = null;
    protected RangeCollection m_ranges = null;
    protected ElementCollection m_values = null;
    protected int rulesCount = 5;
    protected int subRulesCount = 5;
    protected int fontHeightPixel = 8;

    public BaseGuage()
    {
        super();
    }

    public void setValueLimits(double lfMin,double lfMax)
    {
        m_limites = new Range(lfMin,lfMax);
    }

    public Range addRange(Range range)
    {
        if(null == range)
        {
            return range;
        }
        if(null == m_ranges)
        {
            m_ranges = new RangeCollection();
        }
        m_ranges.add(range);
        return range;
    }

    public void addValue(double[] lfValues)
    {
        for(int n = 0;null != lfValues && n < lfValues.length;n++)
        {
            addValue(new Element(lfValues[n]));
        }
    }

    public void addValue(double lfValue)
    {
        addValue(new Element(lfValue));
    }

    public void addValue(double lfValue,Color clr)
    {
        Element e = new Element(lfValue);
        e.setFillColor(clr);
        e.setStrokeColor(clr);
        addValue(e);
    }

    public Element addValue(Element e)
    {
        if(null == e)
        {
            return e;
        }
        if(m_values == null)
        {
            m_values = new ElementCollection();
        }
        m_values.add(e);
        return e;
    }

    public void setRulesCount(int rulesCount)
    {
        this.rulesCount = rulesCount;
    }

    public void setSubRulesCount(int subRulesCount)
    {
        this.subRulesCount = subRulesCount;
    }

    public void setFontHeightPixel(int fontHeightPixel)
    {
        this.fontHeightPixel = fontHeightPixel;
    }

}
